import os
from google.appengine.ext import db
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template

class Account(db.Model):
	google_account = db.UserProperty()
	username = db.StringProperty()
	userid = db.StringProperty()
	password = db.StringProperty()
	master = db.StringProperty()
	denied_list = db.StringListProperty()
	prefer_list = db.StringListProperty()
	date = db.DateTimeProperty(auto_now_add=True)
	
class AccountPage(webapp.RequestHandler):
	def get(self):
		if users.get_current_user():
			url_linktext = 'Logout'
		else:
			url = users.create_login_url(self.request.uri)
			url_linktext = 'Login'

		acounts = Account.all().filter('google_account=', google_account).order('-date')
		
		template_values = {
			'accounts': accounts,
			'url_linktext': url_linktext,
		}
		
		
		
		path = os.path.join(os.path.dirname(__file__), 'template/account.html')
		self.response.out.write(template.render(path, template_values))
